package chapter12

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/17 21:44
  * @history:
  *          1.2019/1/17 created by chuhaitao
  */
object StreamDemo {


  def main(args: Array[String]): Unit = {


    def numsForm(n: BigInt): Stream[BigInt] = n #:: numsForm(n + 1)


    var stream1 = numsForm(1);

    println(stream1.head)

    println(stream1)


    //使用


    def multi(n:BigInt) :BigInt={

      n*n
    }

    var stream2= numsForm(5).map(multi);
    println(stream2)
  }
}
